package MVC.view;

import java.util.ArrayList;
import java.util.HashMap;

import javax.swing.JButton;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreeNode;

import org.jdesktop.swingx.treetable.DefaultMutableTreeTableNode;
import org.jdesktop.swingx.treetable.DefaultTreeTableModel;

import test.Result;
import test.methodResult;

public class MyTreeModel extends DefaultTreeModel {

	private HashMap<Integer,ArrayList<methodResult>> mR = new HashMap<Integer,ArrayList<methodResult>>();
	private boolean showAll = true;
	

	public MyTreeModel(TreeNode root) {
		super(root);
	}

	public HashMap<Integer, ArrayList<methodResult>> getmR() {
		return mR;
	}
	
	public void setShowAll(boolean showAll) {
		this.showAll = showAll;
	}

	public boolean isShowAll() {
		return showAll;
	}
	
	public void updateResults(Result result){
		mR.putAll(result.getMethodResults());
	}

	
	@Override
	public Object getChild(Object node, int idx){
		if (node instanceof TreeNode && ((MyTreeNode)node).isChecked()){
			return ((MyTreeNode) node).getChildAt(idx);
			}
	    else
	        return null;
	}
	
	@Override
	public int getChildCount(Object node){
		if (node instanceof TreeNode && ((MyTreeNode)node).isChecked())
			return ((MyTreeNode) node).getChildCount();
	    else
	    	return 0;
	}
}

